package day5;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import day5.Student;

/**
 * ClassName：TestObject
 *
 * @Author：小鱼
 * @Create：2025-08-22 10:29
 */
public class TestObject {
    public static void main(String[] args) throws Exception{
//        Student s = new Student("张三",18);
//        //写到文件中
//        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("D:\\IDEA_project\\JP_Java\\week6\\src\\day5\\3.txt "));
//        oos.writeObject(s);
//        //关闭资源
//        oos.close();



        //读
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("D:\\IDEA_project\\JP_Java\\week6\\src\\day5\\3.txt "));
        Student s = (Student) ois.readObject();
        System.out.println("s: "+s);
        ois.close();
    }
}
